Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-5086-12634 Agent model refactor. #3338

Merged
merged 63 commits into from
Dec 16, 2024
Merged

Conversation

JiriCtvrtka
Copy link
Contributor

@JiriCtvrtka JiriCtvrtka commented Nov 25, 2024

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 62.87129% with 300 lines in your changes missing coverage. Please review.

Project coverage is 45.28%. Comparing base (a55a663) to head (03ac18e).
Report is 1 commits behind head on v3.

Files with missing lines Patch % Lines
managed/services/inventory/agents.go 53.57% 65 Missing ⚠️
managed/services/management/mysql.go 0.00% 45 Missing ⚠️
managed/services/management/postgresql.go 0.00% 38 Missing ⚠️
managed/models/encryption_helpers.go 60.29% 27 Missing ⚠️
managed/services/management/mongodb.go 0.00% 24 Missing ⚠️
managed/services/management/azure_database.go 0.00% 18 Missing ⚠️
managed/services/management/proxysql.go 0.00% 13 Missing ⚠️
managed/services/agents/mysql.go 8.33% 10 Missing and 1 partial ⚠️
managed/services/agents/postgresql.go 43.75% 8 Missing and 1 partial ⚠️
managed/services/converters.go 84.90% 8 Missing ⚠️
... and 13 more
Additional details and impacted files
@@            Coverage Diff             @@
##               v3    #3338      +/-   ##
==========================================
+ Coverage   43.53%   45.28%   +1.74%     
==========================================
  Files         366      193     -173     
  Lines       44169    28720   -15449     
==========================================
- Hits        19230    13006    -6224     
+ Misses      23254    14531    -8723     
+ Partials     1685     1183     -502     
Flag Coverage Δ
admin ?
agent ?
managed 45.28% <62.87%> (+0.04%) ⬆️
vmproxy ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

now, now)
assertCheckViolation(t, err, "agents", "node_id_or_service_id_for_non_pmm_agent")
})
})
})
}

func TestDatabaseMigrations(t *testing.T) {
Copy link
Contributor Author

@JiriCtvrtka JiriCtvrtka Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed because to have this one working we need two encryption structures. So test is removed and we have only one encryption struct for V3.

var DefaultAgentEncryptionColumnsV3 = []encryption.Table{
	{
		Name:        "agents",
		Identifiers: []string{"agent_id"},
		Columns: []encryption.Column{
			{Name: "username"},
			{Name: "password"},
			{Name: "agent_password"},
			{Name: "aws_options", CustomHandler: EncryptAWSOptionsHandler},
			{Name: "azure_options", CustomHandler: EncryptAzureOptionsHandler},
			{Name: "mongo_options", CustomHandler: EncryptMongoDBOptionsHandler},
			{Name: "mysql_options", CustomHandler: EncryptMySQLOptionsHandler},
			{Name: "postgresql_options", CustomHandler: EncryptPostgreSQLOptionsHandler},
		},
	},
}

// DefaultAgentEncryptionColumns contains all tables and it's columns to be encrypted in PMM Server DB.
var DefaultAgentEncryptionColumns = []encryption.Table{
	{
		Name:        "agents",
		Identifiers: []string{"agent_id"},
		Columns: []encryption.Column{
			{Name: "username"},
			{Name: "password"},
			{Name: "agent_password"},
			{Name: "aws_access_key"},
			{Name: "aws_secret_key"},
			{Name: "azure_options", CustomHandler: EncryptAzureOptionsHandler},
			{Name: "mongo_db_tls_options", CustomHandler: EncryptMongoDBOptionsHandler},
			{Name: "mysql_options", CustomHandler: EncryptMySQLOptionsHandler},
			{Name: "postgresql_options", CustomHandler: EncryptPostgreSQLOptionsHandler},
		},
	},
}

@JiriCtvrtka JiriCtvrtka marked this pull request as ready for review December 5, 2024 14:10
@JiriCtvrtka JiriCtvrtka requested a review from a team as a code owner December 5, 2024 14:10
@JiriCtvrtka JiriCtvrtka requested review from BupycHuk, idoqo and ademidoff and removed request for a team December 5, 2024 14:10
`UPDATE agents SET postgresql_options = '{}'::jsonb WHERE postgresql_options IS NULL`,

`UPDATE agents SET exporter_options = jsonb_set(exporter_options, '{expose_exporter}', to_jsonb(expose_exporter));`,
`UPDATE agents SET exporter_options = jsonb_set(exporter_options, '{push_metrics}', to_jsonb(push_metrics));`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was wondering if we need a where push_metrics is not null here to avoid getting {"push_metrics": null}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@idoqo I think no, because pushMetrics was bool on top of agent not *bool. So I think there should not be case with nil for push_metrics. But correct me if I am wrong.

@JiriCtvrtka JiriCtvrtka merged commit fba3928 into v3 Dec 16, 2024
13 checks passed
@JiriCtvrtka JiriCtvrtka deleted the PMM-5086-12634-agent-refactor branch December 16, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants